+Thu Mar 15 18:22:44 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkcellrenderer.h: Changed prototype to allow for getting
+ the location of the cell relative to its area.
+ * gtk/gtkcell*: modified for above change
+ * gtk/gtktreeview.c: modified for above change.
+
+Wed Mar 14 13:58:32 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreeview.c (gtk_tree_view_set_model): Ref the model.
+ (gtk_tree_view_finalize): actually unref the model. Thanks to
+ Jamie Strachan <frostfreek@yahoo.com> for noticing this error.
+
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
-
+
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
+Thu Mar 15 18:22:44 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkcellrenderer.h: Changed prototype to allow for getting
+ the location of the cell relative to its area.
+ * gtk/gtkcell*: modified for above change
+ * gtk/gtktreeview.c: modified for above change.
+
+Wed Mar 14 13:58:32 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreeview.c (gtk_tree_view_set_model): Ref the model.
+ (gtk_tree_view_finalize): actually unref the model. Thanks to
+ Jamie Strachan <frostfreek@yahoo.com> for noticing this error.
+
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
-
+
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
+Thu Mar 15 18:22:44 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkcellrenderer.h: Changed prototype to allow for getting
+ the location of the cell relative to its area.
+ * gtk/gtkcell*: modified for above change
+ * gtk/gtktreeview.c: modified for above change.
+
+Wed Mar 14 13:58:32 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreeview.c (gtk_tree_view_set_model): Ref the model.
+ (gtk_tree_view_finalize): actually unref the model. Thanks to
+ Jamie Strachan <frostfreek@yahoo.com> for noticing this error.
+
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
-
+
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
+Thu Mar 15 18:22:44 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkcellrenderer.h: Changed prototype to allow for getting
+ the location of the cell relative to its area.
+ * gtk/gtkcell*: modified for above change
+ * gtk/gtktreeview.c: modified for above change.
+
+Wed Mar 14 13:58:32 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreeview.c (gtk_tree_view_set_model): Ref the model.
+ (gtk_tree_view_finalize): actually unref the model. Thanks to
+ Jamie Strachan <frostfreek@yahoo.com> for noticing this error.
+
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
-
+
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
+Thu Mar 15 18:22:44 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkcellrenderer.h: Changed prototype to allow for getting
+ the location of the cell relative to its area.
+ * gtk/gtkcell*: modified for above change
+ * gtk/gtktreeview.c: modified for above change.
+
+Wed Mar 14 13:58:32 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreeview.c (gtk_tree_view_set_model): Ref the model.
+ (gtk_tree_view_finalize): actually unref the model. Thanks to
+ Jamie Strachan <frostfreek@yahoo.com> for noticing this error.
+
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
-
+
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
+Thu Mar 15 18:22:44 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkcellrenderer.h: Changed prototype to allow for getting
+ the location of the cell relative to its area.
+ * gtk/gtkcell*: modified for above change
+ * gtk/gtktreeview.c: modified for above change.
+
+Wed Mar 14 13:58:32 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreeview.c (gtk_tree_view_set_model): Ref the model.
+ (gtk_tree_view_finalize): actually unref the model. Thanks to
+ Jamie Strachan <frostfreek@yahoo.com> for noticing this error.
+
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
-
+
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
+Thu Mar 15 18:22:44 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtkcellrenderer.h: Changed prototype to allow for getting
+ the location of the cell relative to its area.
+ * gtk/gtkcell*: modified for above change
+ * gtk/gtktreeview.c: modified for above change.
+
+Wed Mar 14 13:58:32 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreeview.c (gtk_tree_view_set_model): Ref the model.
+ (gtk_tree_view_finalize): actually unref the model. Thanks to
+ Jamie Strachan <frostfreek@yahoo.com> for noticing this error.
+
2001-03-14 Havoc Pennington <hp@redhat.com>
* gtk/gtkdata.h, gtk/gtkdata.c: Delete.
* configure.in: handle case where X render exists, but Pango lacks
Xft support.
-
+
2001-03-15 Alexander Larsson <alexl@redhat.com>
* gtk/gtktoolbar.[ch]:
enum {
PROP_ZERO,
+ PROP_CAN_ACTIVATE,
PROP_VISIBLE,
PROP_XALIGN,
PROP_YALIGN,
gtk_object_ref (GTK_OBJECT (cell));
gtk_object_sink (GTK_OBJECT (cell));
+ cell->can_activate = FALSE;
cell->visible = TRUE;
cell->xalign = 0.5;
cell->yalign = 0.5;
class->render = NULL;
class->get_size = NULL;
+ g_object_class_install_property (object_class,
+ PROP_CAN_ACTIVATE,
+ g_param_spec_boolean ("can_activate",
+ _("can_activate"),
+ _("Cell can get activate events."),
+ FALSE,
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE));
+
g_object_class_install_property (object_class,
PROP_VISIBLE,
g_param_spec_boolean ("visible",
TRUE,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
-
+
g_object_class_install_property (object_class,
PROP_XALIGN,
g_param_spec_float ("xalign",
0.0,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
-
+
g_object_class_install_property (object_class,
PROP_YALIGN,
g_param_spec_float ("yalign",
0.5,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
-
+
g_object_class_install_property (object_class,
PROP_XPAD,
g_param_spec_uint ("xpad",
2,
G_PARAM_READABLE |
G_PARAM_WRITABLE));
-
+
g_object_class_install_property (object_class,
PROP_YPAD,
g_param_spec_uint ("ypad",
switch (param_id)
{
+ case PROP_CAN_ACTIVATE:
+ g_value_set_boolean (value, cell->can_activate);
+ break;
case PROP_VISIBLE:
g_value_set_boolean (value, cell->visible);
break;
switch (param_id)
{
+ case PROP_CAN_ACTIVATE:
+ cell->can_activate = g_value_get_boolean (value);
+ g_object_notify (object, "can_activate");
+ break;
case PROP_VISIBLE:
cell->visible = g_value_get_boolean (value);
g_object_notify (object, "visible");
* gtk_cell_renderer_get_size:
* @cell: a #GtkCellRenderer
* @widget: the widget the renderer is rendering to
+ * @cell_area: The area a cell will be allocated, or %NULL
+ * @x_offset: location to return x offset of cell relative to @cell_area, or %NULL
+ * @y_offset: location to return y offset of cell relative to @cell_area, or %NULL
* @width: location to return width needed to render a cell, or %NULL
* @height: location to return height needed to render a cell, or %NULL
- *
- * Obtains the width and height needed to render the cell. Used by
- * view widgets to determine the appropriate size for the cell_area
- * passed to gtk_cell_renderer_render().
+ *
+ * Obtains the width and height needed to render the cell. Used by view widgets
+ * to determine the appropriate size for the cell_area passed to
+ * gtk_cell_renderer_render(). If @cell_area is not %NULL, fills in the x and y
+ * offsets (if set) of the cell relative to this location.
**/
void
gtk_cell_renderer_get_size (GtkCellRenderer *cell,
- GtkWidget *widget,
- gint *width,
- gint *height)
+ GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
+ gint *width,
+ gint *height)
{
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->get_size != NULL);
- GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (cell, widget, width, height);
+ GTK_CELL_RENDERER_GET_CLASS (cell)->get_size (cell, widget, cell_area, x_offset, y_offset, width, height);
}
/**
* @background_area rectangles for all cells tile to cover the entire
* @window. Cell renderers can use the @background_area to draw custom expanders, for
* example. @expose_area is a clip rectangle.
- *
+ *
**/
void
gtk_cell_renderer_render (GtkCellRenderer *cell,
* @background_area: background area as passed to gtk_cell_renderer_render()
* @cell_area: cell area as passed to gtk_cell_renderer_render()
* @flags: render flags
- *
+ *
* Passes an event to the cell renderer for possible processing. Some
* cell renderers may use events; for example, #GtkCellRendererToggle
* toggles when it gets a mouse click.
- *
+ *
* Return value: %TRUE if the event was consumed/handled
**/
gint
{
GtkObject parent;
+ gboolean can_activate;
gboolean visible;
gfloat xalign;
/* vtable - not signals */
void (* get_size) (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height);
GtkType gtk_cell_renderer_get_type (void);
void gtk_cell_renderer_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height);
void gtk_cell_renderer_render (GtkCellRenderer *cell,
static void gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class);
static void gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *rectangle,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height);
static void gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell,
static void
gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height)
{
GtkCellRendererPixbuf *cellpixbuf = (GtkCellRendererPixbuf *) cell;
+ GdkPixbuf *pixbuf;
+ gint calc_width;
+ gint calc_height;
+
+ pixbuf = cellpixbuf->pixbuf;
+
+ calc_width = (gint) GTK_CELL_RENDERER (cellpixbuf)->xpad * 2 +
+ (cellpixbuf->pixbuf ? gdk_pixbuf_get_width (cellpixbuf->pixbuf) : 0);
- if (width)
- *width = (gint) GTK_CELL_RENDERER (cellpixbuf)->xpad * 2 +
- (cellpixbuf->pixbuf ? gdk_pixbuf_get_width (cellpixbuf->pixbuf) : 0);
+ calc_height = (gint) GTK_CELL_RENDERER (cellpixbuf)->ypad * 2 +
+ (cellpixbuf->pixbuf ? gdk_pixbuf_get_height (cellpixbuf->pixbuf) : 0);
+
+ if (x_offset) *x_offset = 0;
+ if (y_offset) *y_offset = 0;
+
+ if (cell_area && pixbuf)
+ {
+ if (x_offset)
+ {
+ *x_offset = GTK_CELL_RENDERER (cellpixbuf)->xalign * (cell_area->width - calc_width - (2 * GTK_CELL_RENDERER (cellpixbuf)->xpad));
+ *x_offset = MAX (*x_offset, 0) + GTK_CELL_RENDERER (cellpixbuf)->xpad;
+ }
+ if (y_offset)
+ {
+ *y_offset = GTK_CELL_RENDERER (cellpixbuf)->yalign * (cell_area->height - calc_height - (2 * GTK_CELL_RENDERER (cellpixbuf)->ypad));
+ *y_offset = MAX (*y_offset, 0) + GTK_CELL_RENDERER (cellpixbuf)->ypad;
+ }
+ }
+
+ if (calc_width)
+ *width = calc_width;
if (height)
- *height = (gint) GTK_CELL_RENDERER (cellpixbuf)->ypad * 2 +
- (cellpixbuf->pixbuf ? gdk_pixbuf_get_height (cellpixbuf->pixbuf) : 0);
+ *height = calc_height;
}
static void
GdkPixbuf *pixbuf;
guchar *pixels;
gint rowstride;
- gint real_xoffset;
- gint real_yoffset;
GdkRectangle pix_rect;
GdkRectangle draw_rect;
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
pixels = gdk_pixbuf_get_pixels (pixbuf);
- real_xoffset = GTK_CELL_RENDERER (cellpixbuf)->xalign * (cell_area->width - gdk_pixbuf_get_width (pixbuf) - (2 * GTK_CELL_RENDERER (cellpixbuf)->xpad));
- real_xoffset = MAX (real_xoffset, 0) + GTK_CELL_RENDERER (cellpixbuf)->xpad;
- real_yoffset = GTK_CELL_RENDERER (cellpixbuf)->yalign * (cell_area->height - gdk_pixbuf_get_height (pixbuf) - (2 * GTK_CELL_RENDERER (cellpixbuf)->ypad));
- real_yoffset = MAX (real_yoffset, 0) + GTK_CELL_RENDERER (cellpixbuf)->ypad;
-
- pix_rect.x = cell_area->x + real_xoffset;
- pix_rect.y = cell_area->y + real_yoffset;
- pix_rect.width = gdk_pixbuf_get_width (pixbuf);
- pix_rect.height = gdk_pixbuf_get_height (pixbuf);
+ gtk_cell_renderer_pixbuf_get_size (cell, widget, cell_area,
+ &pix_rect.x,
+ &pix_rect.x,
+ &pix_rect.width,
+ &pix_rect.height);
+ pix_rect.x += cell_area->x;
+ pix_rect.y += cell_area->y;
if (gdk_rectangle_intersect (cell_area, &pix_rect, &draw_rect))
gdk_pixbuf_render_to_drawable_alpha (pixbuf,
GParamSpec *pspec);
static void gtk_cell_renderer_text_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height);
static void gtk_cell_renderer_text_render (GtkCellRenderer *cell,
static void
gtk_cell_renderer_text_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height)
{
PangoLayout *layout;
layout = get_layout (celltext, widget, FALSE, 0);
-
pango_layout_get_pixel_extents (layout, NULL, &rect);
if (width)
if (height)
*height = GTK_CELL_RENDERER (celltext)->ypad * 2 + rect.height;
+ if (cell_area)
+ {
+ if (x_offset)
+ {
+ *x_offset = cell->xalign * (cell_area->width - rect.width - (2 * cell->xpad));
+ *x_offset = MAX (*x_offset, 0) + cell->xpad;
+ }
+ if (y_offset)
+ {
+ *y_offset = cell->yalign * (cell_area->height - rect.height - (2 * cell->ypad));
+ *y_offset = MAX (*y_offset, 0) + cell->ypad;
+ }
+ }
+
g_object_unref (G_OBJECT (layout));
}
{
GtkCellRendererText *celltext = (GtkCellRendererText *) cell;
- PangoRectangle rect;
PangoLayout *layout;
GtkStateType state;
-
- gint real_xoffset;
- gint real_yoffset;
+ gint x_offset;
+ gint y_offset;
layout = get_layout (celltext, widget, TRUE, flags);
- pango_layout_get_pixel_extents (layout, NULL, &rect);
-
- real_xoffset = cell->xalign * (cell_area->width - rect.width - (2 * cell->xpad));
- real_xoffset = MAX (real_xoffset, 0) + cell->xpad;
- real_yoffset = cell->yalign * (cell_area->height - rect.height - (2 * cell->ypad));
- real_yoffset = MAX (real_yoffset, 0) + cell->ypad;
+ gtk_cell_renderer_text_get_size (cell, widget, cell_area, &x_offset, &y_offset, NULL, NULL);
if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED)
state = GTK_STATE_SELECTED;
cell_area,
widget,
"cellrenderertext",
- cell_area->x + real_xoffset,
- cell_area->y + real_yoffset,
+ cell_area->x + x_offset,
+ cell_area->y + y_offset,
layout);
g_object_unref (G_OBJECT (layout));
static void gtk_cell_renderer_text_pixbuf_class_init (GtkCellRendererTextPixbufClass *class);
static void gtk_cell_renderer_text_pixbuf_get_size (GtkCellRenderer *cell,
GtkWidget *view,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height);
static void gtk_cell_renderer_text_pixbuf_render (GtkCellRenderer *cell,
typedef void (* CellSizeFunc) (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *rectangle,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height);
typedef void (* CellRenderFunc) (GtkCellRenderer *cell,
static void
gtk_cell_renderer_text_pixbuf_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height)
{
gint pixbuf_height;
gint text_width;
gint text_height;
-
- (* GTK_CELL_RENDERER_CLASS (parent_class)->get_size) (cell, widget, &text_width, &text_height);
+ gint calc_width;
+ gint calc_height;
+
+ (* GTK_CELL_RENDERER_CLASS (parent_class)->get_size) (cell, widget, NULL, NULL, NULL, &text_width, &text_height);
(* GTK_CELL_RENDERER_CLASS (G_OBJECT_GET_CLASS (celltextpixbuf->pixbuf))->get_size) (GTK_CELL_RENDERER (celltextpixbuf->pixbuf),
widget,
+ NULL, NULL, NULL,
&pixbuf_width,
&pixbuf_height);
if (celltextpixbuf->pixbuf_pos == GTK_POS_LEFT ||
celltextpixbuf->pixbuf_pos == GTK_POS_RIGHT)
{
- if (width)
- *width = pixbuf_width + text_width;
- if (height)
- *height = MAX (pixbuf_height, text_height);
+ calc_width = pixbuf_width + text_width;
+ calc_height = MAX (pixbuf_height, text_height);
}
else
{
- if (width)
- *width = MAX (pixbuf_width, text_width);
- if (height)
- *height = pixbuf_height + text_height;
+ calc_width = MAX (pixbuf_width, text_width);
+ calc_height = pixbuf_height + text_height;
+ }
+
+ if (width)
+ *width = calc_width;
+ if (height)
+ *height = calc_height;
+
+ if (cell_area)
+ {
+ if (x_offset)
+ {
+ *x_offset = cell->xalign * (cell_area->width - calc_width - (2 * cell->xpad));
+ *x_offset = MAX (*x_offset, 0) + cell->xpad;
+ }
+ if (y_offset)
+ {
+ *y_offset = cell->yalign * (cell_area->height - calc_height - (2 * cell->ypad));
+ *y_offset = MAX (*y_offset, 0) + cell->ypad;
+ }
}
}
cell2 = GTK_CELL_RENDERER (celltextpixbuf->pixbuf);
}
- (size_func1) (cell1, widget, &tmp_width, &tmp_height);
+ (size_func1) (cell1, widget, NULL, NULL, NULL, &tmp_width, &tmp_height);
real_cell_area.x = cell_area->x;
real_cell_area.y = cell_area->y;
static void gtk_cell_renderer_toggle_class_init (GtkCellRendererToggleClass *class);
static void gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height);
static void gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
{
celltoggle->active = FALSE;
celltoggle->radio = FALSE;
+ GTK_CELL_RENDERER (celltoggle)->can_activate = TRUE;
GTK_CELL_RENDERER (celltoggle)->xpad = 2;
GTK_CELL_RENDERER (celltoggle)->ypad = 2;
}
static void
gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
gint *width,
gint *height)
{
+ gint calc_width;
+ gint calc_height;
+
+ calc_width = (gint) cell->xpad * 2 + TOGGLE_WIDTH;
+ calc_height = (gint) cell->ypad * 2 + TOGGLE_WIDTH;
+
if (width)
- *width = (gint) cell->xpad * 2 + TOGGLE_WIDTH;
+ *width = calc_width;
if (height)
- *height = (gint) cell->ypad * 2 + TOGGLE_WIDTH;
+ *height = calc_height;
+
+ if (cell_area)
+ {
+ if (x_offset)
+ {
+ *x_offset = cell->xalign * (cell_area->width - calc_width - (2 * cell->xpad));
+ *x_offset = MAX (*x_offset, 0) + cell->xpad;
+ }
+ if (y_offset)
+ {
+ *y_offset = cell->yalign * (cell_area->height - calc_height - (2 * cell->ypad));
+ *y_offset = MAX (*y_offset, 0) + cell->ypad;
+ }
+ }
}
static void
{
GtkCellRendererToggle *celltoggle = (GtkCellRendererToggle *) cell;
gint width, height;
- gint real_xoffset, real_yoffset;
+ gint x_offset, y_offset;
GtkShadowType shadow;
GtkStateType state;
width = MIN (TOGGLE_WIDTH, cell_area->width - cell->xpad * 2);
height = MIN (TOGGLE_WIDTH, cell_area->height - cell->ypad * 2);
+ gtk_cell_renderer_toggle_get_size (cell, widget, cell_area,
+ &x_offset, &y_offset,
+ &width, &height);
+
if (width <= 0 || height <= 0)
return;
- real_xoffset = cell->xalign * (cell_area->width - width - (2 * cell->xpad));
- real_xoffset = MAX (real_xoffset, 0) + cell->xpad;
- real_yoffset = cell->yalign * (cell_area->height - height - (2 * cell->ypad));
- real_yoffset = MAX (real_yoffset, 0) + cell->ypad;
-
shadow = celltoggle->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED)
state = GTK_STATE_SELECTED;
+ else if (! cell->can_activate)
+ state = GTK_STATE_INSENSITIVE;
else
state = GTK_STATE_NORMAL;
window,
state, shadow,
cell_area, widget, "cellradio",
- cell_area->x + real_xoffset,
- cell_area->y + real_yoffset,
+ cell_area->x + x_offset,
+ cell_area->y + y_offset,
width, height);
}
else
window,
state, shadow,
cell_area, widget, "cellcheck",
- cell_area->x + real_xoffset,
- cell_area->y + real_yoffset,
+ cell_area->x + x_offset,
+ cell_area->y + y_offset,
width, height);
}
}
gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0);
gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
+ gdk_draw_rectangle (window,
+ style->black_gc, FALSE,
+ x, y, width, height);
+
+ gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_SOLID, 0, 0);
+ }
+ else if (detail && strcmp (detail, "treeview") == 0)
+ {
+
+ gdk_gc_set_background (style->black_gc, &style->white);
+ gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_DOUBLE_DASH, 0, 0);
+ gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
+
gdk_draw_rectangle (window,
style->black_gc, FALSE,
x, y, width, height);
#define GTK_TREE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TREE_MODEL, GtkTreeModel))
#define GTK_IS_TREE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TREE_MODEL))
#define GTK_TREE_MODEL_GET_IFACE(obj) ((GtkTreeModelIface *)g_type_interface_peek (((GTypeInstance *)GTK_TREE_MODEL (obj))->g_class, GTK_TYPE_TREE_MODEL))
-
typedef struct _GtkTreeIter GtkTreeIter;
typedef struct _GtkTreePath GtkTreePath;
GdkEventButton *event);
static gboolean gtk_tree_view_button_release (GtkWidget *widget,
GdkEventButton *event);
+static void gtk_tree_view_set_focus_child (GtkContainer *container,
+ GtkWidget *child);
static void gtk_tree_view_draw_focus (GtkWidget *widget);
static gint gtk_tree_view_focus_in (GtkWidget *widget,
GdkEventFocus *event);
o_class->get_property = gtk_tree_view_get_property;
object_class->destroy = gtk_tree_view_destroy;
-
+
widget_class->realize = gtk_tree_view_realize;
widget_class->unrealize = gtk_tree_view_unrealize;
widget_class->map = gtk_tree_view_map;
GtkTreeView *tree_view = (GtkTreeView *) object;
GList *list;
+ g_object_unref (G_OBJECT (tree_view->priv->model));
gtk_tree_view_unref_tree (tree_view, tree_view->priv->tree);
for (list = tree_view->priv->columns; list; list = list->next)
}
-static void
-gtk_tree_view_draw_node_focus_rect (GtkWidget *widget,
- GtkTreePath *path)
-{
- GtkTreeView *tree_view;
- GtkRBTree *tree = NULL;
- GtkRBNode *node = NULL;
- gint bin_window_width = 0;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_TREE_VIEW (widget));
-
- tree_view = GTK_TREE_VIEW (widget);
-
- _gtk_tree_view_find_node (tree_view, path, &tree, &node);
-
- if (tree == NULL)
- return;
-
- gdk_drawable_get_size (tree_view->priv->bin_window,
- &bin_window_width, NULL);
-
- /* FIXME need a style function appropriate for this */
- gdk_draw_rectangle (tree_view->priv->bin_window,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- FALSE,
- 0,
- BACKGROUND_FIRST_PIXEL (tree_view, tree, node),
- bin_window_width - 2,
- BACKGROUND_HEIGHT (node) - 1);
-}
-
GdkPixmap*
gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
GtkTreePath *path)
{
GtkTreeViewColumn *column = list->data;
GdkRectangle cell_area;
+ gboolean visible;
if (!column->visible)
continue;
cell_area.x += depth * tree_view->priv->tab_offset;
cell_area.width -= depth * tree_view->priv->tab_offset;
}
- if (cell->visible)
+
+ g_object_get (G_OBJECT (cell), "visible", &visible, NULL);
+ if (visible)
gtk_cell_renderer_render (cell,
drawable,
widget,
if (i == tree_view->priv->expander_column &&
TREE_VIEW_DRAW_EXPANDERS(tree_view))
{
+ gboolean visible;
+
cell_area.x += depth*tree_view->priv->tab_offset;
cell_area.width -= depth*tree_view->priv->tab_offset;
*/
highlight_x = cell_area.x;
- if (cell->visible)
+ g_object_get (G_OBJECT (cell), "visible", &visible, NULL);
+ if (visible)
gtk_cell_renderer_render (cell,
event->window,
widget,
}
else
{
- if (cell->visible)
+ gboolean visible;
+ g_object_get (G_OBJECT (cell), "visible", &visible, NULL);
+
+ if (visible)
gtk_cell_renderer_render (cell,
event->window,
widget,
cell_offset += column->displayed_width;
}
- if (node == cursor &&
- GTK_WIDGET_HAS_FOCUS (widget))
+ if (node == cursor && GTK_WIDGET_HAS_FOCUS (widget))
gtk_tree_view_draw_focus (widget);
if (node == drag_highlight)
/* Draw indicator for the drop
*/
gint highlight_y = -1;
+ GtkRBTree *tree = NULL;
+ GtkRBNode *node = NULL;
+ gint width;
switch (tree_view->priv->drag_dest_pos)
{
case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE:
case GTK_TREE_VIEW_DROP_INTO_OR_AFTER:
- gtk_tree_view_draw_node_focus_rect (widget,
- drag_dest_path);
+ _gtk_tree_view_find_node (tree_view, drag_dest_path, &tree, &node);
+
+ if (tree == NULL)
+ break;
+ gdk_drawable_get_size (tree_view->priv->bin_window,
+ &width, NULL);
+ gtk_paint_focus (widget->style,
+ tree_view->priv->bin_window,
+ NULL,
+ widget,
+ "add-mode",
+ 0, BACKGROUND_FIRST_PIXEL (tree_view, tree, node),
+ width - 1, BACKGROUND_HEIGHT (node) - 1);
+
break;
}
GtkTreeViewColumn *column = list->data;
GtkCellRenderer *cell;
GtkTreeIter iter;
+ gboolean visible;
if (!column->visible)
continue;
&iter);
path_string = gtk_tree_path_to_string (path);
- if (cell->visible &&
- gtk_cell_renderer_event (cell,
- (GdkEvent *)event,
- widget,
- path_string,
- &background_area,
- &cell_area,
- 0))
+
+ g_object_get (G_OBJECT (cell), "visible", &visible, NULL);
+ if (visible && gtk_cell_renderer_event (cell,
+ (GdkEvent *)event,
+ widget,
+ path_string,
+ &background_area,
+ &cell_area,
+ 0))
{
g_free (path_string);
gtk_tree_path_free (path);
return TRUE;
}
+static void
+gtk_tree_view_set_focus_child (GtkContainer *container,
+ GtkWidget *child)
+{
+}
static void
gtk_tree_view_draw_focus (GtkWidget *widget)
{
GtkTreeView *tree_view;
GtkTreePath *cursor_path;
+ GtkRBTree *tree = NULL;
+ GtkRBNode *node = NULL;
+ gint x, y;
+ gint width, height;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_TREE_VIEW (widget));
if (cursor_path == NULL)
return;
- gtk_tree_view_draw_node_focus_rect (widget, cursor_path);
+ _gtk_tree_view_find_node (tree_view, cursor_path, &tree, &node);
+
+ if (tree == NULL)
+ {
+ gtk_tree_path_free (cursor_path);
+ return;
+ }
+
+ gdk_drawable_get_size (tree_view->priv->bin_window,
+ &width, NULL);
+
+
+ x = 0;
+ y = BACKGROUND_FIRST_PIXEL (tree_view, tree, node);
+ gdk_drawable_get_size (tree_view->priv->bin_window,
+ &width, NULL);
+ width = width - 1;
+ height = BACKGROUND_HEIGHT (node) - 1;
+ if (tree_view->priv->focus_column != NULL)
+ {
+ GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN (tree_view->priv->focus_column->data);
+ gboolean visible;
+ gboolean can_focus;
+
+ g_object_get (G_OBJECT (column->cell),
+ "can_activate", &can_focus,
+ "visible", &visible,
+ NULL);
+ if (can_focus && visible)
+ {
+ GtkTreeIter iter;
+ GdkRectangle cell_area;
+ gint x_offset;
+ gint y_offset;
+
+ cell_area.x = column->button->allocation.x;
+ cell_area.y = y;
+ cell_area.width = column->displayed_width;
+ cell_area.height = CELL_HEIGHT (node);
+
+ gtk_tree_model_get_iter (tree_view->priv->model, &iter, cursor_path);
+ gtk_tree_view_column_set_cell_data (column, tree_view->priv->model, &iter);
+
+ gtk_cell_renderer_get_size (column->cell, GTK_WIDGET (tree_view), &cell_area, &x_offset, &y_offset, &width, &height);
+ width += 2;
+ height += 2;
+ x = cell_area.x + x_offset - 1;
+ y = cell_area.y + y_offset - 1 + TREE_VIEW_VERTICAL_SEPARATOR/2;
+ }
+ }
+
+ gtk_paint_focus (widget->style,
+ tree_view->priv->bin_window,
+ NULL,
+ widget,
+ "add-mode",
+ x, y, width, height);
+
+ gtk_tree_path_free (cursor_path);
}
case GTK_DIR_DOWN:
if (focus_child == NULL)
{
- if (tree_view->priv->focus_column == NULL)
- focus_child = GTK_TREE_VIEW_COLUMN (first_column->data)->button;
- else
+ if (tree_view->priv->focus_column != NULL)
focus_child = GTK_TREE_VIEW_COLUMN (tree_view->priv->focus_column->data)->button;
+ else
+ focus_child = GTK_TREE_VIEW_COLUMN (first_column->data)->button;
gtk_widget_grab_focus (focus_child);
break;
}
case GTK_DIR_RIGHT:
if (focus_child == NULL)
{
- g_assert_not_reached ();
- return FALSE;
+ if (tree_view->priv->focus_column != NULL)
+ focus_child = GTK_TREE_VIEW_COLUMN (tree_view->priv->focus_column->data)->button;
+ else if (dir == GTK_DIR_LEFT)
+ focus_child = GTK_TREE_VIEW_COLUMN (last_column->data)->button;
+ else
+ focus_child = GTK_TREE_VIEW_COLUMN (first_column->data)->button;
+ gtk_widget_grab_focus (focus_child);
+ break;
}
if (gtk_container_focus (GTK_CONTAINER (focus_child), dir))
*/
if (focus_child)
{
+ for (tmp_list = tree_view->priv->columns; tmp_list; tmp_list = tmp_list->next)
+ if (GTK_TREE_VIEW_COLUMN (tmp_list->data)->button == focus_child)
+ break;
+
+ tree_view->priv->focus_column = tmp_list;
+
/* If the following isn't true, then the view is smaller then the scrollpane.
*/
if ((focus_child->allocation.x + focus_child->allocation.width) <=
return (focus_child != NULL);
}
-/* WARNING: Scary function */
+/* WARNING: Somewhat scary function */
+/* We make the assumption that if container->focus_child != NULL, the focus must
+ * be in the header. For now, this is accurate. It may not be in the future.
+ */
static gint
gtk_tree_view_focus (GtkContainer *container,
GtkDirectionType direction)
if (!GTK_WIDGET_IS_SENSITIVE (container))
return FALSE;
- if (tree_view->priv->tree == NULL)
- return FALSE;
focus_child = container->focus_child;
return FALSE;
case GTK_DIR_TAB_FORWARD:
case GTK_DIR_DOWN:
+
+ if (tree_view->priv->tree == NULL)
+ return FALSE;
+
GTK_TREE_VIEW_SET_FLAG (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS);
gtk_widget_grab_focus (GTK_WIDGET (container));
{
if ((direction == GTK_DIR_TAB_FORWARD) ||
(direction == GTK_DIR_RIGHT) ||
- (direction == GTK_DIR_DOWN))
- {
- if (gtk_tree_view_header_focus (tree_view, direction))
- return TRUE;
- }
+ (direction == GTK_DIR_DOWN) ||
+ (direction == GTK_DIR_LEFT) ||
+ (tree_view->priv->tree == NULL))
+ return gtk_tree_view_header_focus (tree_view, direction);
/* The headers didn't want the focus, so we take it. */
GTK_TREE_VIEW_SET_FLAG (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS);
return TRUE;
}
+ /* Case 3. We have focus already. */
+ if (tree_view->priv->tree == NULL)
+ return FALSE;
+
+ if (direction == GTK_DIR_TAB_BACKWARD)
+ return (gtk_tree_view_header_focus (tree_view, direction));
+ else if (direction == GTK_DIR_TAB_FORWARD)
+ return FALSE;
+
cursor_path = NULL;
if (tree_view->priv->cursor)
cursor_path = gtk_tree_row_reference_get_path (tree_view->priv->cursor);
- /* Case 3. We have focus already, but no cursor. We pick the first one
- * and run with it.
- */
-
+ /* Do we have a focus path? We should, unless it was deleted. */
+ /* in that case, we pick the first one arbitrarily */
if (cursor_path == NULL)
{
GtkTreePath *tmp_path = gtk_tree_path_new_root ();
/* At this point, we've progressed beyond the edge of the rows. */
- if ((direction == GTK_DIR_LEFT) ||
- (direction == GTK_DIR_TAB_BACKWARD) ||
- (direction == GTK_DIR_UP))
+ if (direction == GTK_DIR_UP)
/* We can't go back anymore. Try the headers */
return (gtk_tree_view_header_focus (tree_view, direction));
gint i = 0;
gboolean free_path = FALSE;
+ if (tree_view->priv->tree == NULL)
+ tree_view->priv->tree = _gtk_rbtree_new ();
+
tmptree = tree = tree_view->priv->tree;
g_return_if_fail (path != NULL || iter != NULL);
if (GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_SHOW_EXPANDERS))
{
GList *list;
+
for (list = tree_view->priv->columns; list; list = list->next)
if (GTK_TREE_VIEW_COLUMN (list->data)->visible)
{
g_assert (tree_view->priv->prelight_node == NULL);
- if ((tree->root->count == 1) &&
- (tree_view->priv->tree != tree))
+ if (tree->root->count == 1)
{
+ if (tree_view->priv->tree == tree)
+ tree_view->priv->tree = NULL;
+
_gtk_rbtree_remove (tree);
}
else
cell = column->cell;
gtk_tree_view_column_set_cell_data (column, tree_view->priv->model, iter);
- gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), &width, &height);
+ gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), NULL, NULL, NULL, &width, &height);
max_height = MAX (max_height, TREE_VIEW_VERTICAL_SEPARATOR + height);
if (i == tree_view->priv->expander_column &&
gtk_tree_view_column_set_cell_data (column, tree_view->priv->model, iter);
cell = column->cell;
- gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), &width, &height);
+ gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), NULL, NULL, NULL, &width, &height);
max_height = MAX (max_height, TREE_VIEW_VERTICAL_SEPARATOR + height);
/* FIXME: I'm getting the width of all nodes here. )-: */
if (height)
{
- gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), &width, &tmpheight);
+ gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), NULL, NULL, NULL, &width, &tmpheight);
*height = MAX (*height, tmpheight);
}
else
{
- gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), &width, NULL);
+ gtk_cell_renderer_get_size (cell, GTK_WIDGET (tree_view), NULL, NULL, NULL, &width, NULL);
}
if (i == tree_view->priv->expander_column &&
TREE_VIEW_DRAW_EXPANDERS (tree_view))
GtkTreePath *path;
GtkTreeIter iter;
- tree_view->priv->tree = _gtk_rbtree_new ();
+ tree_view->priv->tree = NULL;
g_signal_connectc (tree_view->priv->model,
"changed",
if (gtk_tree_model_get_iter (tree_view->priv->model, &iter, path))
{
+ tree_view->priv->tree = _gtk_rbtree_new ();
gtk_tree_view_build_tree (tree_view, tree_view->priv->tree, &iter, 1, FALSE, GTK_WIDGET_REALIZED (tree_view));
}
}
tree_view->priv->model = model;
+ g_object_ref (model);
if (model == NULL)
{
tree_view->priv->tree = NULL;
_gtk_tree_view_column_unset_tree_view (column);
- if (GTK_TREE_VIEW_COLUMN (tree_view->priv->focus_column->data) == column)
+ if (tree_view->priv->focus_column &&
+ GTK_TREE_VIEW_COLUMN (tree_view->priv->focus_column->data) == column)
tree_view->priv->focus_column = NULL;
tree_view->priv->columns = g_list_remove (tree_view->priv->columns, column);
update_button_contents (tree_column);
g_object_notify (G_OBJECT (tree_column), "sort_indicator");
+ if (GTK_WIDGET_REALIZED (tree_column->tree_view))
+ gtk_widget_queue_draw (tree_column->tree_view);
}
}
gboolean visible);
gboolean gtk_tree_view_column_get_visible (GtkTreeViewColumn *tree_column);
void gtk_tree_view_column_set_sizing (GtkTreeViewColumn *tree_column,
- GtkTreeViewColumnSizing type);
+ GtkTreeViewColumnSizing type);
gint gtk_tree_view_column_get_sizing (GtkTreeViewColumn *tree_column);
gint gtk_tree_view_column_get_width (GtkTreeViewColumn *tree_column);
void gtk_tree_view_column_set_width (GtkTreeViewColumn *tree_column,
gboolean gtk_tree_view_column_get_clickable (GtkTreeViewColumn *tree_column);
void gtk_tree_view_column_set_widget (GtkTreeViewColumn *tree_column,
GtkWidget *widget);
-GtkWidget * gtk_tree_view_column_get_widget (GtkTreeViewColumn *tree_column);
+GtkWidget *gtk_tree_view_column_get_widget (GtkTreeViewColumn *tree_column);
void gtk_tree_view_column_set_alignment (GtkTreeViewColumn *tree_column,
gfloat xalign);
gfloat gtk_tree_view_column_get_alignment (GtkTreeViewColumn *tree_column);
#endif /* __cplusplus */
#endif /* __GTK_TREE_VIEW_COLUMN_H__ */
+
guint time)
{
GtkWidget *source_widget;
+ GList *tmp_list;
if (!have_drag)
{
GTK_OBJECT_TYPE_NAME (source_widget) :
"NULL");
+ tmp_list = context->targets;
+ while (tmp_list)
+ {
+ char *name = gdk_atom_name (GPOINTER_TO_UINT (tmp_list->data));
+ g_print ("%s\n", name);
+ g_free (name);
+
+ tmp_list = tmp_list->next;
+ }
+
gdk_drag_status (context, context->suggested_action, time);
return TRUE;
}
guint time)
{
GtkWidget *source_widget;
+ GList *tmp_list;
if (!have_drag)
{
GTK_OBJECT_TYPE_NAME (source_widget) :
"NULL");
+ tmp_list = context->targets;
+ while (tmp_list)
+ {
+ char *name = gdk_atom_name (GPOINTER_TO_UINT (tmp_list->data));
+ g_print ("%s\n", name);
+ g_free (name);
+
+ tmp_list = tmp_list->next;
+ }
+
gdk_drag_status (context, context->suggested_action, time);
return TRUE;
}
struct _TreeStruct
{
const gchar *label;
+ gboolean alex;
gboolean havoc;
+ gboolean tim;
gboolean owen;
+ gboolean world_holiday; /* shared by the european hackers */
TreeStruct *children;
};
static TreeStruct january[] =
{
- {"New Years Day", TRUE, TRUE, NULL},
- {"Presidential Inauguration", TRUE, TRUE, NULL},
- {"Martin Luther King Jr. day", TRUE, TRUE, NULL},
+ {"New Years Day", TRUE, TRUE, TRUE, TRUE, TRUE, NULL},
+ {"Presidential Inauguration", FALSE, TRUE, FALSE, TRUE, FALSE, NULL},
+ {"Martin Luther King Jr. day", FALSE, TRUE, FALSE, TRUE, FALSE, NULL},
{ NULL }
};
static TreeStruct february[] =
{
- { "Presidents' Day", TRUE, TRUE, NULL },
- { "Groundhog Day", FALSE, FALSE, NULL },
- { "Valentine's Day", FALSE, FALSE, NULL },
+ { "Presidents' Day", FALSE, TRUE, FALSE, TRUE, FALSE, NULL },
+ { "Groundhog Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Valentine's Day", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
{ NULL }
};
static TreeStruct march[] =
{
- { "National Tree Planting Day", FALSE, FALSE, NULL },
- { "St Patrick's Day", FALSE, FALSE, NULL },
+ { "National Tree Planting Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "St Patrick's Day", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
{ NULL }
};
static TreeStruct april[] =
{
- { "April Fools' Day", FALSE, FALSE, NULL },
- { "Army Day", FALSE, FALSE, NULL },
- { "Earth Day", FALSE, FALSE, NULL },
- { "Administrative Professionals' Day", FALSE, FALSE, NULL },
+ { "April Fools' Day", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
+ { "Army Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Earth Day", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
+ { "Administrative Professionals' Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ NULL }
};
static TreeStruct may[] =
{
- { "Nurses' Day", FALSE, FALSE, NULL },
- { "National Day of Prayer", FALSE, FALSE, NULL },
- { "Mothers' Day", FALSE, FALSE, NULL },
- { "Armed Forces Day", FALSE, FALSE, NULL },
- { "Memorial Day", TRUE, TRUE, NULL },
+ { "Nurses' Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "National Day of Prayer", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Mothers' Day", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
+ { "Armed Forces Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Memorial Day", TRUE, TRUE, TRUE, TRUE, TRUE, NULL },
{ NULL }
};
static TreeStruct june[] =
{
- { "June Fathers' Day", FALSE, FALSE, NULL },
- { "Juneteenth (Liberation of Slaves)", FALSE, FALSE, NULL },
- { "Flag Day", TRUE, TRUE, NULL },
+ { "June Fathers' Day", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
+ { "Juneteenth (Liberation of Slaves)", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Flag Day", FALSE, TRUE, FALSE, TRUE, FALSE, NULL },
{ NULL }
};
static TreeStruct july[] =
{
- { "Parents' Day", FALSE, FALSE, NULL },
- { "Independence Day", TRUE, TRUE, NULL },
+ { "Parents' Day", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
+ { "Independence Day", FALSE, TRUE, FALSE, TRUE, FALSE, NULL },
{ NULL }
};
static TreeStruct august[] =
{
- { "Air Force Day", FALSE, FALSE, NULL },
- { "Coast Guard Day", FALSE, FALSE, NULL },
- { "Friendship Day", FALSE, FALSE, NULL },
+ { "Air Force Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Coast Guard Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Friendship Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ NULL }
};
static TreeStruct september[] =
{
- { "Grandparents' Day", FALSE, FALSE, NULL },
- { "Citizenship Day or Constitution Day", FALSE, FALSE, NULL },
- { "Labor Day", TRUE, TRUE, NULL },
+ { "Grandparents' Day", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
+ { "Citizenship Day or Constitution Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Labor Day", TRUE, TRUE, TRUE, TRUE, TRUE, NULL },
{ NULL }
};
static TreeStruct october[] =
{
- { "National Children's Day", FALSE, FALSE, NULL },
- { "Bosses' Day", FALSE, FALSE, NULL },
- { "Sweetest Day", FALSE, FALSE, NULL },
- { "Mother-in-Law's Day", FALSE, FALSE, NULL },
- { "Navy Day", FALSE, FALSE, NULL },
- { "Columbus Day", TRUE, TRUE, NULL },
- { "Halloween", FALSE, FALSE, NULL },
+ { "National Children's Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Bosses' Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Sweetest Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Mother-in-Law's Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Navy Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Columbus Day", FALSE, TRUE, FALSE, TRUE, FALSE, NULL },
+ { "Halloween", FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
{ NULL }
};
static TreeStruct november[] =
{
- { "Marine Corps Day", FALSE, FALSE, NULL },
- { "Veterans' Day", TRUE, TRUE, NULL },
- { "Thanksgiving", TRUE, TRUE, NULL },
+ { "Marine Corps Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Veterans' Day", TRUE, TRUE, TRUE, TRUE, TRUE, NULL },
+ { "Thanksgiving", FALSE, TRUE, FALSE, TRUE, FALSE, NULL },
{ NULL }
};
static TreeStruct december[] =
{
- { "Pearl Harbor Remembrance Day", FALSE, FALSE, NULL },
- { "Christmas", TRUE, TRUE, NULL },
- { "Kwanzaa", FALSE, FALSE, NULL },
+ { "Pearl Harbor Remembrance Day", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+ { "Christmas", TRUE, TRUE, TRUE, TRUE, TRUE, NULL },
+ { "Kwanzaa", FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ NULL }
};
static TreeStruct toplevel[] =
{
- {"January", FALSE, FALSE, january},
- {"February", FALSE, FALSE, february},
- {"March", FALSE, FALSE, march},
- {"April", FALSE, FALSE, april},
- {"May", FALSE, FALSE, may},
- {"June", FALSE, FALSE, june},
- {"July", FALSE, FALSE, july},
- {"August", FALSE, FALSE, august},
- {"September", FALSE, FALSE, september},
- {"October", FALSE, FALSE, october},
- {"November", FALSE, FALSE, november},
- {"December", FALSE, FALSE, december},
+ {"January", FALSE, FALSE, FALSE, FALSE, FALSE, january},
+ {"February", FALSE, FALSE, FALSE, FALSE, FALSE, february},
+ {"March", FALSE, FALSE, FALSE, FALSE, FALSE, march},
+ {"April", FALSE, FALSE, FALSE, FALSE, FALSE, april},
+ {"May", FALSE, FALSE, FALSE, FALSE, FALSE, may},
+ {"June", FALSE, FALSE, FALSE, FALSE, FALSE, june},
+ {"July", FALSE, FALSE, FALSE, FALSE, FALSE, july},
+ {"August", FALSE, FALSE, FALSE, FALSE, FALSE, august},
+ {"September", FALSE, FALSE, FALSE, FALSE, FALSE, september},
+ {"October", FALSE, FALSE, FALSE, FALSE, FALSE, october},
+ {"November", FALSE, FALSE, FALSE, FALSE, FALSE, november},
+ {"December", FALSE, FALSE, FALSE, FALSE, FALSE, december},
{NULL}
};
enum
{
HOLIDAY_COLUMN = 0,
+ ALEX_COLUMN,
HAVOC_COLUMN,
+ TIM_COLUMN,
OWEN_COLUMN,
VISIBLE_COLUMN,
+ WORLD_COLUMN,
NUM_COLUMNS
};
TreeStruct *month = toplevel;
GtkTreeIter iter;
- model = gtk_tree_store_new_with_types (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
+ model = gtk_tree_store_new_with_types (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
while (month->label)
{
gtk_tree_store_append (model, &iter, NULL);
gtk_tree_store_set (model, &iter,
HOLIDAY_COLUMN, month->label,
+ ALEX_COLUMN, FALSE,
HAVOC_COLUMN, FALSE,
+ TIM_COLUMN, FALSE,
OWEN_COLUMN, FALSE,
VISIBLE_COLUMN, FALSE,
+ WORLD_COLUMN, FALSE,
-1);
while (holiday->label)
{
gtk_tree_store_append (model, &child_iter, &iter);
gtk_tree_store_set (model, &child_iter,
HOLIDAY_COLUMN, holiday->label,
+ ALEX_COLUMN, holiday->alex,
HAVOC_COLUMN, holiday->havoc,
+ TIM_COLUMN, holiday->tim,
OWEN_COLUMN, holiday->owen,
VISIBLE_COLUMN, TRUE,
+ WORLD_COLUMN, holiday->world_holiday,
-1);
holiday ++;
return GTK_TREE_MODEL (model);
}
+static void
+alex_toggled (GtkCellRendererToggle *cell,
+ gchar *path_str,
+ gpointer data)
+{
+ GtkTreeModel *model = (GtkTreeModel *) data;
+ GtkTreeIter iter;
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ gboolean alex;
+
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter, ALEX_COLUMN, &alex, -1);
+
+ alex = !alex;
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter, ALEX_COLUMN, alex, -1);
+
+ gtk_tree_path_free (path);
+}
+
static void
havoc_toggled (GtkCellRendererToggle *cell,
gchar *path_str,
static void
owen_toggled (GtkCellRendererToggle *cell,
- gchar *path_str,
- gpointer data)
+ gchar *path_str,
+ gpointer data)
{
GtkTreeModel *model = (GtkTreeModel *) data;
GtkTreeIter iter;
gtk_tree_path_free (path);
}
+static void
+tim_toggled (GtkCellRendererToggle *cell,
+ gchar *path_str,
+ gpointer data)
+{
+ GtkTreeModel *model = (GtkTreeModel *) data;
+ GtkTreeIter iter;
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ gboolean tim;
+
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter, TIM_COLUMN, &tim, -1);
+
+ tim = !tim;
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter, TIM_COLUMN, tim, -1);
+
+ gtk_tree_path_free (path);
+}
+
+
int
main (int argc, char *argv[])
{
GtkWidget *tree_view;
GtkTreeModel *model;
GtkCellRenderer *renderer;
+ gint col_offset;
+ GtkTreeViewColumn *column;
gtk_init (&argc, &argv);
model = make_model ();
tree_view = gtk_tree_view_new_with_model (model);
- // g_object_set (G_OBJECT (tree_view), "model", model, NULL);
+ g_object_unref (G_OBJECT (model));
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE);
+
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
-1, "Holiday",
renderer,
"text", HOLIDAY_COLUMN, NULL);
g_object_unref (renderer);
+
+ /* Alex Column */
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_signal_connect_data (G_OBJECT (renderer), "toggled", alex_toggled, model, NULL, FALSE, FALSE);
+
+ g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL);
+ col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
+ -1, "Alex",
+ renderer,
+ "active", ALEX_COLUMN,
+ "visible", VISIBLE_COLUMN,
+ "can_activate", WORLD_COLUMN,
+ NULL);
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
+ gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_width (GTK_TREE_VIEW_COLUMN (column), 50);
+ g_object_unref (renderer);
+
+ /* Havoc Column */
renderer = gtk_cell_renderer_toggle_new ();
g_signal_connect_data (G_OBJECT (renderer), "toggled", havoc_toggled, model, NULL, FALSE, FALSE);
g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL);
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
- -1, "Havoc",
+ col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
+ -1, "Havoc",
+ renderer,
+ "active", HAVOC_COLUMN,
+ "visible", VISIBLE_COLUMN,
+ NULL);
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
+ gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_width (GTK_TREE_VIEW_COLUMN (column), 50);
+ g_object_unref (renderer);
+
+ /* Tim Column */
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_signal_connect_data (G_OBJECT (renderer), "toggled", tim_toggled, model, NULL, FALSE, FALSE);
+
+ g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL);
+ col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
+ -1, "Tim",
renderer,
- "active", HAVOC_COLUMN,
+ "active", TIM_COLUMN,
"visible", VISIBLE_COLUMN,
+ "can_activate", WORLD_COLUMN,
NULL);
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
+ gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_width (GTK_TREE_VIEW_COLUMN (column), 50);
g_object_unref (renderer);
+
+ /* Owen Column */
renderer = gtk_cell_renderer_toggle_new ();
g_signal_connect_data (G_OBJECT (renderer), "toggled", owen_toggled, model, NULL, FALSE, FALSE);
g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL);
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
+ col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
-1, "Owen",
renderer,
"active", OWEN_COLUMN,
"visible", VISIBLE_COLUMN,
NULL);
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (tree_view), col_offset - 1);
+ gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_width (GTK_TREE_VIEW_COLUMN (column), 50);
g_object_unref (renderer);
- gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
+ gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
gtk_widget_show_all (window);
+
gtk_main ();
return 0;